<template>
	<z-paging ref="paging" class="balance-list" v-model="datalist" @query="queryList" default-page-size="15">
		<view slot="top">
			<view class="top-search">
				<input type="text" v-model="params.keywords" placeholder="请输入要搜索的内容" class="input" />
				<image src="../../static/images/user/search.png" class="image" @click="getRecords"></image>
			</view>
		</view>
		<view class="balance-list-box">
			<view class="balance-list-item" v-for="(item, i) in datalist" :key="i">
				<view class="item-left">
					<view class="t0">{{ item.memo }}</view>
					<view class="t1">{{ item.createtime }}</view>
				</view>
				<view class="item-right">
					<view class="t0">{{ item.money }}</view>
					<view class="t1">{{ item.type }}</view>
				</view>
			</view>
		</view>
	</z-paging>
</template>

<script>
	import api from '@/api/index.js';
	export default {
		data() {
			return {
				params: {
					keywords: '',
					type: null
				},
				datalist: []
			};
		},
		methods: {
			/**
			 * 获取余额记录
			 */
			queryList(pageNo, pageSize) {
				api.getMoneylog({
					page: pageNo,
					limit: pageSize,
				}).then(res => {
					this.$refs.paging.complete(res.data.data);
				}).catch(res => {
					this.$refs.paging.complete(false);
				})
			},
			goTocharge() {
				uni.redirectTo({
					url: 'user/recharge' // 跳转到对应路径的页面
				});
			}
		}
	};
</script>

<style lang="scss">
	.balance-list {
		background: #f8f8f8;
		padding: 28rpx;
		.top-search {
			background: #ffffff;
			box-shadow: 0px 12rpx 116rpx 0px rgba(196, 203, 214, 0.1);
			border-radius: 24rpx;
			display: flex;
			align-items: center;
			padding: 26rpx 40rpx;
			margin: 20rpx 20rpx 0;
			.input {
				flex: 1;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 32rpx;
				color: #7d8592;
				line-height: 44rpx;
				text-align: left;
				font-style: normal;
			}

			.image {
				width: 48rpx;
				height: 48rpx;
			}
		}

		.balance-list-box {
			margin: 20rpx;
			.balance-list-item {
				background: #ffffff;
				box-shadow: 0px 4rpx 8rpx 0px rgba(41, 121, 255, 0.05);
				border-radius: 16rpx;
				border: 2rpx solid;
				border-image: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1)) 1 1;
				padding: 26rpx 30rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 20rpx;

				.item-left {
					.t0 {
						font-family: PingFangSC, PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						color: #413100;
						line-height: 40rpx;
						font-style: normal;
					}

					.t1 {
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #666666;
						line-height: 34rpx;
						font-style: normal;
					}
				}

				.item-right {
					text-align: right;
					.t0 {
						font-family: PingFangSC, PingFang SC;
						font-weight: 600;
						font-size: 32rpx;
						color: #f95452;
						line-height: 44rpx;
						font-style: normal;
					}

					.t1 {
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #999999;
						line-height: 34rpx;
						font-style: normal;
					}
				}
			}
		}
	}
</style>